package com.nbsaas.boot.app.rest.convert;

import com.nbsaas.boot.app.data.entity.AppRole;
import com.nbsaas.boot.app.api.domain.simple.AppRoleSimple;

import com.nbsaas.boot.rest.api.Converter;

/**
* 角色-列表对象转换器
*/

public class AppRoleSimpleConvert implements Converter<AppRoleSimple, AppRole> {




@Override
public AppRoleSimple convert(AppRole source) {
    AppRoleSimple result = new AppRoleSimple();


               try {
                   if(source.getApp()!=null){
                       result.setApp(source.getApp().getId());
                   }
                } catch (Exception ignored) { }

                result.setDataViewPeriod(source.getDataViewPeriod());

                try {
                    if(source.getApp()!=null){
                        result.setAppName(source.getApp().getName());
                    }
                } catch (Exception ignored) { }

                result.setReportViewPeriod(source.getReportViewPeriod());
                result.setName(source.getName());
                result.setTenantId(source.getTenantId());
                result.setBillViewPeriod(source.getBillViewPeriod());
                result.setRemark(source.getRemark());
                result.setId(source.getId());
                if(source.getRoleType()!=null){
                    result.setRoleTypeName(String.valueOf(source.getRoleType()));
                }
                result.setRoleType(source.getRoleType());
                result.setAddDate(source.getAddDate());
                result.setLastDate(source.getLastDate());


    return result;
}

}